<?php
header("content-type:text/html;charset=utf8");
// print_r($_POST);
/*
[name] => qwerqwer
[pass] => qwerqwer
[tel] => 13212345678
[email] => 123456@qq.com
*/
$name = $_POST['name'];
$pass = $_POST['pass'];
$tel = $_POST['tel'];
$email = $_POST['email'];

// 查询用户名是否被注册过
$con = mysqli_connect("localhost","root","root","hf_2102");
mysqli_query($con,"set names utf8");
$res = mysqli_query($con,"select * from user where username='$name'");
$row = mysqli_fetch_assoc($res);
if($row){
    // 用户名被注册过了
    echo 1;
}else{
    // 用户名没有被注册过
    $res = mysqli_query($con,"insert user(username,password,tel,email) values('$name','$pass',$tel,'$email')");
    if($res){
        // 新增成功
        echo 2;
    }else{
        // 新增失败
        echo 3;
    }
}